package com.liqi.monitor.service.impl;


import java.util.List;

import com.liqi.common.annotation.DataScope;
import com.liqi.common.utils.DateUtils;
import com.liqi.deployment.domain.DvDeployment;
import com.liqi.deployment.mapper.DvDeploymentMapper;
import com.liqi.monitor.domain.DvMaitenance;
import com.liqi.monitor.mapper.DvMaitenanceMapper;
import com.liqi.monitor.service.IDvMaitenanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 分组Service业务层处理
 *
 * @author zhangh
 * @date 2022-10-19
 */
@Service
public class DvMaitenanceServiceImpl implements IDvMaitenanceService
{
    @Autowired
    private DvMaitenanceMapper dvMaitenanceMapper;
    @Autowired
    private DvDeploymentMapper dvDeploymentMapper;

//    /**
//     * 查询分组
//     *
//     * @param id 分组主键
//     * @return 分组
//     */
//    @Override
//    public DvMaitenance selectDvMaitenanceById(Long id)
//    {
//        return dvMaitenanceMapper.selectDvMaitenanceById(id);
//    }

    /**
     * 查询分组列表
     *
     * @param dvMaitenance 分组
     * @return 分组
     */
    @DataScope(deptAlias = "d" , userAlias = "u",regionAlias = "r",groupAlias = "g")
    @Override
    public List<DvMaitenance> selectDvMaitenanceList(DvMaitenance dvMaitenance)
    {
        return dvMaitenanceMapper.selectDvMaitenanceList(dvMaitenance);
    }

    /**
     * 新增分组
     *
     * @param dvMaitenance 分组
     * @return 结果
     */
    @Override
    public int insertDvMaitenance(DvMaitenance dvMaitenance)
    {
    	DvDeployment dvDeployment = dvDeploymentMapper.selectDvDeploymentByDeviceId(dvMaitenance.getDeviceId());
    	dvMaitenance.setDeptId(dvDeployment.getDeptId());
    	dvMaitenance.setCreateUserId(dvMaitenance.getOperationUserCode());
    	dvMaitenance.setCreateTime(DateUtils.getNowDate());
        return dvMaitenanceMapper.insertDvMaitenance(dvMaitenance);
    }

    /**
     * 修改分组
     *
     * @param dvMaitenance 分组
     * @return 结果
     */
    @Override
    public int updateDvMaitenance(DvMaitenance dvMaitenance)
    {
        return dvMaitenanceMapper.updateDvMaitenance(dvMaitenance);
    }
//
//    /**
//     * 批量删除分组
//     *
//     * @param ids 需要删除的分组主键
//     * @return 结果
//     */
//    @Override
//    public int deleteDvMaitenanceByIds(Long[] ids)
//    {
//        return dvMaitenanceMapper.deleteDvMaitenanceByIds(ids);
//    }
//
//    /**
//     * 删除分组信息
//     *
//     * @param id 分组主键
//     * @return 结果
//     */
//    @Override
//    public int deleteDvMaitenanceById(Long id)
//    {
//        return dvMaitenanceMapper.deleteDvMaitenanceById(id);
//    }
}
